package com.glut.gultguy.mapper;

import com.glut.gultguy.entity.Goods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since 2022-09-05
 */
public interface GoodsMapper extends BaseMapper<Goods> {

    @Update("update goods set clicks = (clicks+1) where id = #{goodId}")
    int addClick(String goodId);

    @Select("select goodsState from goods where id = #{goodId}")
    int getStatus(String goodId);

    @Update("update goods set current_price = #{price} where id = #{goodId}")
    int updatePrice(String goodId,Integer price);

    @Select("select * from goods where name like #{key}")
    List<Goods> search(String key);

    @Select("select * from goods where publisher_id = #{publisherId}")
    List<Goods> getMyGoods(String publisherId);

    @Select("select * from goods where buyer_openid = #{buyerOpenId} order by end_time desc")
    List<Goods> getDeal(String buyerOpenId);
}
